/*** Trigger Name: fulfillmentStepDefinition
 * Author: Accenture
 * Date: 06-Jun-2011
 * Requirement/Project Name: iFulfill
 * Requirement Description: When ever Task name is updated in the 
 *                          task pre-definition object then assoicated workflow's task name will be modified.
 **/
trigger fulfillmentStepDefinition on Step_Definition__c (after update) {

    list<Wokflow_Steps__c> workflowStepList = new list<Wokflow_Steps__c>();
    Map<id,String> stepMap = new Map<id,string>();  
    if (Trigger.isUpdate) {
           for(Step_Definition__c SD :trigger.new){
                if(SD.Name != Trigger.oldMap.get(SD.id).Name){stepMap.put(SD.id, SD.name);}  
           }
           for(Wokflow_Steps__c WS :[select Id,Name,Step__c from Wokflow_Steps__c where Step__c = :stepMap.keyset()]){
                 WS.Name=stepMap.get(WS.Step__c);  
                 workflowStepList.add(WS); 
            } 
     } 
      try{if(workflowStepList.size()>0){update workflowStepList;} 
      }catch(Exception e){
         system.debug(e);  
         GeneralConstants.mailAnyExceptionToMe('FulfillmentStepDefinitionTrigger', 'Update Taskname' , e);
       }

}